﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Service.BusinessLayer.Entities;
using Service.DataAccess.DataAccessHelper;
using System.Data.SqlClient;
using System.Data;

namespace Service.DataAccess.DataAccessLogic
{
    public class ChiTietGiaoHang_DA
    {
        public void them(ChiTietGiaoHang ctgh)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[6];
            par[0] = new SqlParameter("@masg", ctgh.Masg);
            par[1] = new SqlParameter("@mamh", ctgh.Mamh);
            par[2] = new SqlParameter("@mawash", ctgh.Mawash);
            par[3] = new SqlParameter("@soluonggiao", ctgh.Soluonggiao);
            par[4] = new SqlParameter("@thanhtien", ctgh.Thanhtien);
            par[5] = new SqlParameter("@ghichu", ctgh.Ghichu);
            help.InsertQuery("sp_chitietgiaohang_them", par);
        }
        public void sua(ChiTietGiaoHang ctgh)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[6];
            par[0] = new SqlParameter("@masg", ctgh.Masg);
            par[1] = new SqlParameter("@mamh", ctgh.Mamh);
            par[2] = new SqlParameter("@mawash", ctgh.Mawash);
            par[3] = new SqlParameter("@soluonggiao", ctgh.Soluonggiao);
            par[4] = new SqlParameter("@thanhtien", ctgh.Thanhtien);
            par[5] = new SqlParameter("@ghichu", ctgh.Ghichu);
            help.UpdateQuery("sp_chitietgiaohang_sua", par);
        }
        public void xoa(string masg,string mamh)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[2];
            par[0] = new SqlParameter("@masg", masg);
            par[1] = new SqlParameter("@mamh", mamh);
            help.DeleteQuery("sp_chitietgiaohang_xoa", par);
        }
        public DataSet Layds_Theo_MaKH_NgayGiao(int MaKH, DateTime NgayGiao)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[2];
            par[0] = new SqlParameter("@MaKH", MaKH);
            par[1] = new SqlParameter("@NgayGiao", NgayGiao);
            DataSet ds = help.SelectQuery("sp_CTGiaoHang_LaySD_Theo_MaKH_NgayGiao",par);
            return ds;
        }
    }
}
